#pragma once


#include <map>
#include <vector>


class XSkinObjMgr
{
public:
    XSkinObjMgr();
    ~XSkinObjMgr();

    static XSkinObjMgr* instance();

    void Init();
    void UnInit();

public:
    HFONT   GetFont(LONG lFontSize, BOOL bBold, BOOL bItalic, BOOL bUnderline, BOOL bStrikeOut, LPCTSTR szFontName);
    XString GetDefaultFontName();
    HFONT   GetDefaultFont();
    void    ReleaseFont(HFONT hFont);

    HCURSOR GetCursor(LPCTSTR szCursor);
    HCURSOR GetCursor(LPCTSTR szCursor, HMODULE hResModule);
    HCURSOR GetDefaultCursor();
    void    ReleaseCursor(HCURSOR hCursor);

    XCANVAS CreateCanvas(XIMAGE xImage);
    XCANVAS CreateCanvas(int nBitsPerPixel);
    void    DeleteCanvas(XCANVAS xCanvas);

    // Can't be deleted!
    XCANVAS GetTempCanvas(XIMAGE xImage);
    XCANVAS GetTempCanvas(int nBitsPerPixel);

protected:
    void    InitCursor();

    void    InitDefaultFontName();
    void    ReleaseFont();
    void    ReleaseCursor();
    void    ReleaseTempCanvas();

protected:
    // Font
    typedef struct
    {
        LOGFONT     LogFont;
        HFONT       hFont;
    } stFontInfo;
    typedef std::vector<stFontInfo> FontInfoList;
    FontInfoList    m_FontInfoList;
    HFONT           m_hDefaultFont;
    XString         m_strDefaultFontName;

    // Cursor
    typedef struct
    {
        XString     strCursor;
        HCURSOR     hCursor;
        HMODULE     hModule;
        int         nRef;
    } stCursorInfo;
    typedef std::vector<stCursorInfo>   CursorInfoList;
    CursorInfoList  m_CursorInfoList;
    HCURSOR         m_hDefaultCursor;

    // Canvas
    struct TempCanvasInfo
    {
        XCANVAS canvas;
        XIMAGE  xImage;
        XIMAGE  xOldImage;
    };
    typedef std::map<int, TempCanvasInfo>  TempCanvasMap;
    TempCanvasMap   m_TempCanvasMap;
};
